//
//  PersonHeaderView.m
//  PropertyMananger
//
//  Created by bh on 17/3/2.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "PersonHeaderView.h"

@implementation PersonHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.bgView = [[UIView alloc]init];
        [self addSubview:self.bgView];
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).with.offset(0);
            make.leading.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 150));
        }];
        
        
        self.backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:self.backBtn];
      
        [self.backBtn setImage:[UIImage imageNamed:@"ico_return"] forState:UIControlStateNormal];
        
        [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(self).with.offset(30);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];


        
        self.headerBgView = [[UIImageView alloc]init];
        [self.bgView addSubview:self.headerBgView];
        self.headerBgView.image = [UIImage imageNamed:@"bg_personal"];
        
        [self.headerBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).with.offset(0);
            make.leading.equalTo(self).with.offset(0);
            make.size.mas_equalTo(CGSizeMake(BHscreenW, 150));
        }];
        
        //name
        self.nameLabel = [[UILabel alloc]init];
        [self addSubview:self.nameLabel];
        self.nameLabel.text = @"个人信息";
       // self.nameLabel.text = userModel.RealName;
        
        self.nameLabel.textColor = [UIColor whiteColor];
        self.nameLabel.textAlignment = NSTextAlignmentCenter;
        self.nameLabel.font = BHFont(20);
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(15);
            make.top.equalTo(self).with.offset(80);
            make.size.mas_equalTo(CGSizeMake(100, 30));
        }];

        
        //头像
        self.headerImg = [[UIImageView alloc]init];
        [self.bgView addSubview:self.headerImg];
        self.headerImg.image = [UIImage imageNamed:@"ico_user_head"];
        //        self.headerImg.layer.cornerRadius = 10;
        //        self.headerImg.layer.masksToBounds = YES;
        
        [self.headerImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.nameLabel).with.offset(-10);
            make.trailing.equalTo(self).with.offset(-30);
            make.size.mas_equalTo(CGSizeMake(50,50));
        }];
        
    
    }
    return self;
}

@end
